package com.me.mvc.controller.clients;

import java.util.LinkedList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.me.mvc.model.ModelUtils;
import com.me.mvc.model.entity.Client;
import com.me.mvc.model.entity.representation.xml.EntityList;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Roman Uholnikov
 */

@RestController
public class ClientsById {

    @GET
    @RequestMapping(value = "/clients/rest.json", method = RequestMethod.GET)
    @Produces({MediaType.APPLICATION_JSON})
    public EntityList<Client> getClientJson(ModelMap modelMap) {
        return new EntityList<Client>(new LinkedList<Client>(ModelUtils.clientMap.values()));
    }

    @GET
    @RequestMapping(value = "/clients/rest.xml", method = RequestMethod.GET)
    @Produces({MediaType.APPLICATION_XML})
    public EntityList<Client> getClientXml(ModelMap modelMap) {
        return new EntityList<Client>(new LinkedList<Client>(ModelUtils.clientMap.values()));
    }

    @GET
    @RequestMapping(value = "/clients/rest.atom", method = RequestMethod.GET)
    @Produces({MediaType.APPLICATION_ATOM_XML})
    public List<Client> getClientAtom(ModelMap modelMap) {
        return new LinkedList<Client>(ModelUtils.clientMap.values());
    }

    @GET
    @RequestMapping(value = "/clients/rest.rss", method = RequestMethod.GET)
    @Produces({"application/rss+xml"})
    public List<Client> getClientRss(ModelMap modelMap) {
        return new LinkedList<Client>(ModelUtils.clientMap.values());
    }
}
